import request from './request';

// 用户列表查询参数接口
export interface UserListParams {
    pageCode?: string;
    pageSize?: string;
    searchValue?: string;
    type?: string;
    minScore?: string;
    maxScore?: string;
}

// 商店数据接口（根据实际 API 响应）
export interface Shop {
    id: string;
    shopName?: string;
    shopAddress: string;
    shopDescription: string;
    shopTel: string;
    shopImage: string;
    shopScore?: string;
    shopSellCount?: string;
    shopType?: string;
}

// API 响应接口
export interface ShopListResponse {
    data: {
        totalCount: number;
        data: Shop[];
    };
    message: string;
    code: number;
}

// 获取商店列表
export const getShopList = (params: UserListParams = {}): Promise<ShopListResponse> => {
    console.log('API 请求参数:', params);
    return request.get('/list', { params });
};

// 根据 ID 获取商店详情
export const getShopById = (id: string): Promise<Shop> => {
    return request.get(`/shops/${id}`);
};

// 创建商店
export const createShop = (shopData: Partial<Shop>): Promise<Shop> => {
    return request.post('/shops', shopData);
};

// 更新商店
export const updateShop = (id: string, shopData: Partial<Shop>): Promise<Shop> => {
    return request.put(`/shops/${id}`, shopData);
};

// 删除商店
export const deleteShop = (id: string): Promise<void> => {
    return request.delete(`/shops/${id}`);
};

// 批量删除商店
export const batchDeleteUsers = (ids: string[]): Promise<void> => {
    return request.delete('/shops/batch', { data: { ids } });
};
